Conditions are logical expressions that you can use to control the display of fields and sections in your document. Although the following examples apply to fields, they also apply to sections.
条件式とは、論理演算を用いた判定式のことであり、ドキュメント内に配置するフィールドやセクションの表示を制御する際に使用します。ここでの解説では例としてフィールドを使用していますが、セクションの場合でも同様です。
You can define conditions for the following field types:
条件は、次の種類のフィールドに設定できます。
Conditional text: displays text A if the condition is true, or text B if the condition is false.
条件付きテキスト:条件が真の場合はテキスト A を表示し、条件が偽の場合はテキスト B を表示します。
Hidden text: hides the contents of the field if the condition is true.
隠しテキスト:条件が真の場合、フィールドの内容を隠します (表示しません)。
Hidden paragraph: hides the paragraph if the condition is true.
隠し段落:条件が真の場合、段落の内容を隠します (表示しません)。
Any record and next record: controls the access to database records.
任意のレコードと次のレコード:データベースレコードへのアクセスを制御します。
The simplest way to define a condition is to type the logical expression directly in a Condition box using the following values:
条件を定義するもっとも簡単な方法は、次の値を使用して、入力ボックス 条件 に論理表現を直接入力することです。
|
TRUE
|
The condition is always met. You can also enter any value not equal to 0 as the conditional text.
|
|
FALSE
|
The condition is not met. You can also enter the value 0.
|
![]() | If you leave the Condition box empty, the condition is interpreted as not being met.
入力ボックス 条件 を空のままにした場合、条件は「満たされない」ものであると見なされます。 |
When you define a condition, use the same elements for defining a formula, namely comparative operators, mathematical and statistical functions, number formats, variables and constants.
条件式の記述には、通常の数式の構成要素である、比較演算子、数学関数、統計関数、数の書式、変数、定数なども利用します。
You can use the following types of variables when you define a condition:
条件を定義するときには、次の種類の変数を使用できます。
Predefined Office variables that use statistics on document properties
Office の定義済み変数 (ドキュメントのプロパティーで得られる統計情報)
Custom variables, that are a created with the "Set variable" field
ユーザー定義の変数 (「変数の設定」フィールドで作成する)
Variables based on user data
ユーザーデータに基づく変数
Variables based on the contents of database fields
データベースフィールドの内容に基づく変数
You cannot use internal variables, such as page and chapter numbers, in condition expression.
ページ番号や章番号などの内部変数は条件式には使用できません。
The following examples use a variable called "x":
次の例では、変数「x」を使用しています。
|
x == 1 or x EQ 1
|
The condition is true if "x" is equal to 1.
|
|
x != 1 or x NEQ 1
|
The condition is true if "x" does not equal 1.
|
|
sinx == 0
|
The condition is true if "x" is a multiple of pi.
|
To use comparative operators with strings, the operands must be bounded by double quotation marks:
比較演算子を文字列と一緒に使用するには、演算子を二重引用符で囲む必要があります。
|
x == "ABC" or x EQ "ABC"
|
Checks if variable "x" contains (true) the "ABC" string, or not (false).
|
|
x == "" or x EQ ""
or
!x or NOT x
|
Checks if the variable "x" contains an empty string.
|
![]() | The "equal" comparative operator must be represented by two equal signs (==) in a condition. For example, if you define a variable "x" with the value of 1, you can enter the condition as x==1.
「等しい」ことを示す比較演算子を条件で使用する場合、2 つの等号記号 (==) で表現する必要があります。たとえば、値 1 を持つ変数「x」を定義した場合、「FALSE x==1」という条件を入力できます。 |
You can include user data when you define conditions. To change your user data, choose Office - PreferencesTools - Options - Office - User data. User data must be entered in the form of strings. You can query the user data with "==" (EQ), "!=" (NEQ), or "!"(NOT).
[PO-fuzzy@swriter\01.po] ※※※未訳※※※
The following table lists user data variables and their meanings:
次の表に、ユーザーデータの変数とその意味を示します。
|
Variable
|
Meaning
|
|
user_firstname
|
First name
|
|
user_lastname
|
Last name
|
|
user_initials
|
Initials
|
|
user_company
|
Company
|
|
user_street
|
Street
|
|
user_country
|
Country
|
|
user_zipcode
|
Zip code
|
|
user_city
|
City
|
|
user_title
|
Title
|
|
user_position
|
Position
|
|
user_tel_work
|
Business telephone number
|
|
user_tel_home
|
Home telephone number
|
|
user_fax
|
Fax number
|
|
user_email
|
E-mail address
|
|
user_state
|
State (not in all Office versions)
|
For example, to hide a paragraph, text, or a section from a user with a specific initial, such as "LM", enter the condition: user_initials=="LM".
たとえば、特別なイニシャル (たとえば、「LM」) を持つユーザーの場合にのみ、段落、テキスト、またはセクションを隠すには、次の条件を入力します。user_initials=="LM".
You can define conditions for accessing databases, or database fields. For example, you can check the contents of a database field from a condition, or use database fields in logical expressions. The following table lists a few more examples of using databases in conditions:
条件式中では、データベース内のデータベースフィールドにアクセスすることもできます。たとえば条件式を用いて、データベースフィールドの内容を判定させたり、論理式の演算対象として、データベースフィールドを指定することができます。次の表は、条件式中でのデータベースの使用例を簡単にまとめたものです。
|
Example
|
Meaning
|
|
Database.Table.Company
Database.Table.Company NEQ ""
Database.Table.Company != ""
|
The condition is true if the COMPANY field is not empty. (In the first example, no operator is required.)
|
|
!Database.Table.Company
NOT Database.Table.Company
Database.Table.Company EQ ""
Database.Table.Company ==""
|
Returns TRUE if the COMPANY field is empty.
|
|
Database.Table.Company !="Sun"
Database.Table.Company NEQ "Sun"
|
Returns TRUE if the current entry in the COMPANY field is not "Sun". (Exclamation sign represents a logical NOT.)
|
|
Database.Table.Firstname AND Database.Table.Name
|
Returns TRUE if the record contains the first and the last name.
|
![]() | Note the difference between the boolean NOT "!" and the comparative operator not equal "!=" (NEQ).
論理否定 "!" (NOT) と比較演算子「等しくない」"!=" (NEQ) との違いに注意してください。 |
When you refer to a database field in a condition, use the form Databasename.Tablename.Fieldname. If one of the names contains a character that is an operator, such as a minus sign (-), enclose the name in square brackets, for example, Databasename.[Table-name].Fieldname. Never use spaces inside field names.
条件式中でデータベースフィールドを参照する場合は、「データベース名.表名.フィールド名」の形式で指定します。これらの名前の中に、マイナス記号 (-) などの演算子と重なる記号が使われている場合は、「Databasename.[Table-name].Fieldname」のように、名前を大かっこで囲みます。なお、フィールドの名前の中にはスペース記号は使えません。
You may want to create a condition that hides an empty field, for example, if the COMPANY field is empty for some of the data records.
必要であれば、空のフィールドを表示しない条件も作成できます。たとえば、いくつかのデータレコードのうち、フィールド「会社」が空の場合には、次のように入力します。
Select the Hidden Paragraph list entry, and type the following condition: Addressbook.Addresses.Company EQ ""
隠し段落リスト項目を選択し、次の条件を入力します: アドレス帳.アドレス.会社 EQ ""
or type the following
あるいは、次のように入力します。
NOT Addressbook.Addresses.Company
NOT アドレス帳.アドレス.会社
If the COMPANY database field is empty, the condition is true and the paragraph is hidden.
フィールド「会社」が空の場合、条件は真になり、段落は隠されます。
![]() | To display hidden paragraphs on the screen, you can choose Office - PreferencesTools - Options - Office Writer - Formatting Aids, and clear the Fields: Hidden paragraphs check box.
[PO-fuzzy@swriter\01.po] ※※※未訳※※※ |
The following examples use the Conditional text field, although they can be applied to any fields that can be linked to a condition. The syntax used for conditions is also used for the Hidden text, Hidden paragraph, Any record or Next record fields.
次の例では条件付きテキストフィールドを使用していますが、条件に関連するすべてのフィールドに共通です。条件の構文は、隠しテキスト、隠し段落、任意のレコード、または次のレコードの各フィールドにも適用できます。
Choose Insert - Fields - Other, and then click the Functions tab.
メニュー 挿入 → フィールド → その他 を選択して、機能 タブをクリックします。
In the Type list, click "Conditional text".
リスト フィールドタイプ から「条件付きテキスト」を選択します。
In the Condition box, type "page == 1".
入力ボックス 条件 に「page == 1」と入力します。
In the Then box, type "There is only one page".
入力ボックス 条件を満たすとき に「1 ページしかありません。」と入力します。
In the Or box, type "There are several pages".
入力ボックス 条件を満たさないとき に「複数のページがあります。」と入力します。
Click Insert, and then click Close.
挿入 をクリックして、閉じる をクリックします。
Choose Insert - Fields - Other, and then click the Variables tab.
メニュー 挿入 → フィールド → その他 を選択して、変数 タブをクリックします。
In the Type list, click "Set Variable".
リスト フィールドタイプ から「編集の設定」を選択します。
In the Name box, type "Profit".
入力ボックス 名前 に「利益」と入力します。
In the Value box, type "5000".
入力ボックス 値 に「5000」と入力します。
Click Insert.
挿入 をクリックします。
Click the Functions tab, and click "Conditional text" in the Type list.
機能 タブをクリックして、リスト フィールドタイプ から「条件付きテキスト」を選択します。
In the Condition box, type "Profit < 5000".
入力ボックス 条件 に「利益 < 5000」と入力します。
In the Then box, type "Target is not met".
入力ボックス 条件を満たすとき に「該当するものはありません。」と入力します。
In the Or box, type "Target is met".
入力ボックス 条件を満たさないとき に「該当するものがありました。」と入力します。
Click Insert.
挿入 をクリックします。
To edit the contents of the "Profit" variable, double-click the variable field.
「利益」変数の内容を編集するには、変数フィールドをダブルクリックします。
The first part of this example inserts a space between the "First Name" and "Last Name" fields in a document, and the second part inserts text based on the contents of a field. This example requires that an address data source is registered with Office.
この例の最初の部分ではドキュメントの「名」フィールドと「姓」フィールドの間に空白を挿入し、2 つ目の部分ではフィールドの内容にもとづいてテキストを挿入します。 この例は、Office に住所データソースが登録されていることが前提となります。
Choose Insert - Fields - Other, and then click the Database tab.
メニュー 挿入 → フィールド → その他 を選択して、データベース タブをクリックします。
In the Type list, click "Mail merge fields".
リスト フィールドタイプ から「差し込み印刷フィールド」を選択します。
In the Database selection box, double-click an address book, click "First Name", and then click Insert. Repeat for "Last Name".
入力ボックス データベースの選択 で「アドレス帳」をダブルクリックして、「名」を選択し、挿入 をクリックします。「姓」にも同様の手順を行います。
In the document, place the cursor between the two fields, press Space, and then return to the Fields dialog:
ドキュメント内の 2 つのフィールドの間にカーソルを置いて、スペースバーを押し、ダイアログ フィールド に戻ります。
Click the Functions tab, and then click "Conditional text" in the Type list.
機能 タブをクリックして、リスト フィールドタイプ から「条件付きテキスト」を選択します。
In the Condition box, type: "Addressbook.addresses.firstname".
入力ボックス 条件 に、「アドレス帳.アドレス.名」と入力します。
In the Then box, type a space and leave the Or box blank.
入力ボックス 条件を満たすとき に 1 文字のスペースを入力します。入力ボックス 条件を満たさないとき は空のままにします。
You can now use a condition to insert text based on the contents of the First Name field.
これで、「名」フィールドの内容に基づいて条件付きテキストを挿入できるようになりました。
In the Fields dialog, click the Functions tab.
ダイアログ フィールド で、機能 タブをクリックします。
In the Type box, click "Conditional text".
リスト フィールドタイプ から「条件付きテキスト」を選択します。
In the Condition box, type: Addressbook.addresses.firstname == "Michael"
入力ボックス 条件 に、「アドレス帳.アドレス.名 == "Michael"」と入力します。
In the Then box, type "Dear".
入力ボックス 条件を満たすとき に「前略」と入力します。
In the Else box, type "Hello".
条件を満たさないときボックスに「こんにちは」と入力します。
Click Insert.
挿入 をクリックします。